#解释层 对于业务数据进行解释和执行

from glab import *
from __init__ import log

ID2id={}#保存每个模块ID的在hass中的位置信息 ，当 模块主动发送状态时候，更改UI上的状态 
def exp(s=" "):
   a=s.split(' ')
   if a[1]=="08" and a[2]=="88":#��到 04 08 88 21 2B 03 C5
     dom_id=ID2id.get(a[0]+iif(a[3]=="11","0","1"),"None")
     if(dom_id!="None"):
       lights[dom_id]._state=iif(dec(a[4])>0,True,False)
       
       if(a[4]!="00"):lights[dom_id]._brightness=dec(a[4])*2.55
       
       lights[dom_id].schedule_update_ha_state()
       
     return " " + a[0] + "亮度反馈:" + iif(a[3] == "11", "A", "B") + "亮度=" + str(dec(a[4])) + " 加速度=" + a[5] + " index" + str(dom_id)

   if (a[3]=="02"):
    dom_id=ID2id.get(a[0]+a[5][-1],"None")
    if a[4]=="FD" or a[4]=="FC":#继电器 1=00 03 00 02 FD 05 65 
       if(dom_id!="None"):
         lights[dom_id]._state=iif(a[4]=="FD",True,False)
         lights[dom_id].schedule_update_ha_state()
       return " " + a[0] + "开关设定:" + iif(a[4]=="FD","开","关") + " index" + str(dom_id)
    else:#拉菲面板
       return " " + a[0] + "面板按下"

   return "未知"




